package com.caesar.Date.third;

import org.junit.jupiter.api.Test;

import java.time.ZoneId;
import java.time.ZonedDateTime;

/**
 * @author caesar
 * @date 2025/7/15
 * @Description:其他地区的日期时间
 * @apiNote
 */
public class TestZonedDateTime {
    @Test
    public void test1(){
        //本地的日期时间
        ZonedDateTime zdt = ZonedDateTime.now();
        System.out.println(zdt);
        //2025-07-15T09:36:32.291563700+08:00[Asia/Shanghai]
        //of()内填写的时区对应的日期时间
        ZoneId id = ZoneId.of("America/Los_Angeles");;
        ZonedDateTime other = ZonedDateTime.now(id);
        System.out.println(other);
        //2025-07-14T18:36:32.292560500-07:00[America/Los_Angeles]
    }

    @Test
    public void test2(){
        //自己设置年月日时区以及时区
        ZonedDateTime zdt = ZonedDateTime.of(2025, 7, 15, 9, 36, 32, 291563700, ZoneId.of("Asia/Shanghai"));
        System.out.println(zdt );

        ZonedDateTime zdt1 = ZonedDateTime.of(2025, 7, 15, 9, 36, 32, 291563700, ZoneId.of("America/Los_Angeles"));
        System.out.println(zdt1);
    }
}
